#ifdef WIN32
#include <windows.h>
#endif

#include "Utils/CProfilingWindow.h"
#include "Utils/CWindowClass.h"

#include "Utils/listKeyClass.h"
#include "Utils/T2List.h"
#include "Utils/T2AvlList.h"
#include "Utils/T2DLinkedList.h"
#include "CSemaphore.h"
#include "CConsole.h"

CProfilingWindow* CProfilingWindow::m_pClassInstance = NULL;

CProfilingWindow::CProfilingWindow()
{
	window = NULL;
	#ifdef _PROFILING_ENABLED
	window = new CWindowClass();
	window->setWindowName("Profiling Window");
	#endif
}

CProfilingWindow::~CProfilingWindow()
{

}

CProfilingWindow* CProfilingWindow::getInstance()
{
	if (CProfilingWindow::m_pClassInstance == NULL)
	{
		CProfilingWindow::m_pClassInstance = new CProfilingWindow();
	}

	return CProfilingWindow::m_pClassInstance;
}

void CProfilingWindow::setValue(char* key, int newValue)
{
#ifdef _PROFILING_ENABLED
	window->setValue(key, newValue);
#endif
}

void CProfilingWindow::setValue(char* key, char* format ,... )
{
#ifdef _PROFILING_ENABLED
	va_list ap;
	char newValue[1024];

	va_start(ap, format);		// Parses The String For Variables
		vsprintf(newValue, format, ap);	// And Converts Symbols To Actual Numbers
	va_end(ap);

	window->setValueString(key,newValue);
#endif
}

void CProfilingWindow::setValueString(char* key, char* newValue)
{
#ifdef _PROFILING_ENABLED
	window->setValueString(key,newValue);
#endif
}

void CProfilingWindow::setVisible(bool newValue)
{
	#ifdef _PROFILING_ENABLED
	window->setVisible(newValue);
	#endif
}

void CProfilingWindow::toggleVisible()
{
	#ifdef _PROFILING_ENABLED
	window->toggleVisible();
	#endif
}

void CProfilingWindow::setWindowName(char* newName)
{
	#ifdef _PROFILING_ENABLED
	window->setWindowName(newName);
	#endif
}
